<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ include file="/include/taglibs.jsp" %>
<%@ page import="com.gph.saviorframework.common.model.User" %>
<%@ page import="org.apache.shiro.SecurityUtils" %>
<%
    User user = (User) SecurityUtils.getSubject().getPrincipal();
%>
<%@ include file="/include/taglibs.jsp" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page isELIgnored="false" %>
<html>
<head>
    <%@ include file="/include/min_base.jsp" %>
    <link rel="stylesheet" href="${ctx}/css/base.css"/>
    <link rel="stylesheet" href="${ctx}/assets/admin/LingUI/css/bootstrap-select.css" />
    <script src="${ctx}/assets/admin/LingUI/js/bootstrap-select.js" type="text/javascript"></script>
    <title>创建客户端管理信息</title>
    <style>
        .w_auto {
            width: 30%;
            float: left;
            padding: 2px 5px;
        }
        .bootstrap-select.form-control:not([class*="col-"]){
            width:70%;
        }
    </style>
</head>
<body>
<div class="row" style="margin:0px;padding:0px;">
    <div class="col-md-12">
        <h3 class="pub_title"><span>客户端管理信息</span></h3>

        <form id="ayy" method="post" class="form-horizontal">
            <div class="form-group">
                <label for="clientId" class="col-sm-3 control-label" style="font-weight: 500">客户端编号：</label>

                <div class="col-sm-9">
                    <input type="text" class="form-control" id="clientId" name="clientId"
                           required="true" style="width: 70%;float: left;" />
                    <span class="tips">*</span>
                </div>
            </div>
            <div class="form-group">
                <label for="name" class="col-sm-3 control-label" style="font-weight: 500">客户端名称：</label>

                <div class="col-sm-9">
                    <input type="text" class="form-control" id="name" name="name"
                           required="true" style="width: 70%;float: left;" />
                    <span class="tips">*</span>
                </div>
            </div>
            <div class="form-group">
                <label for="clientSecret" class="col-sm-3 control-label" style="font-weight: 500">客户端密码：</label>

                <div class="col-sm-9">
                    <input type="text" class="form-control" id="clientSecret" name="clientSecret"
                           required="true" style="width: 70%;float: left;" />
                    <span class="tips">*</span>
                </div>
            </div>
            <div class="form-group">
                <label for="clientUri" class="col-sm-3 control-label" style="font-weight: 500">客戶端URI：</label>

                <div class="col-sm-9">
                    <input type="text" class="form-control" id="clientUri" name="clientUri"
                           required="true" style="width: 70%;;float: left;" />
                    <span class="tips">*</span>
                </div>
            </div>
            <div class="form-group">
                <label for="iconUri" class="col-sm-3 control-label" style="font-weight: 500">图标Uri：</label>

                <div class="col-sm-9">
                    <input type="text" class="form-control" id="iconUri" name="iconUri"
                           required="true" style="width: 70%;;float: left;" />
                    <span class="tips">*</span>
                </div>
            </div>
            <div class="form-group">
                <label for="resourceIds" class="col-sm-3 control-label" style="font-weight: 500">资源编号：</label>

                <div class="col-sm-9">
                    <input type="text" class="form-control" id="resourceIds" name="resourceIds"
                           required="true" style="width: 70%;;float: left;" />
                    <span class="tips">*</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label" style="font-weight: 500">范围：</label>

                <div class="col-sm-9">
                    <select class="form-control selectpicker" id="scope" class="selectpicker" data-hide-disabled="true" data-size="100"
                            name="scope" data-placeholder="请选择范围..."  style="width: 70%;float: left;">
                        <option value="read">只读</option>
                        <option value="read write">读写</option>
                    </select>
                    <span class="tips">*</span>
                </div>
            </div>
            <div class="form-group">
                <label for="grantTypes" class="col-sm-3 control-label" style="font-weight: 500">许可方式：</label>

                <div class="col-sm-9">
                    <input type="text" class="form-control" id="grantTypes" name="grantTypes"
                           required="true" style="width: 70%;float: left;" />
                    <span class="tips">*</span>
                </div>
            </div>
            <div class="form-group">
                <label for="redirectUri" class="col-sm-3 control-label" style="font-weight: 500">跳转URI：</label>

                <div class="col-sm-9">
                    <input type="text" class="form-control" id="redirectUri" name="redirectUri"
                           required="true" style="width: 70%;float: left;" />
                    <span class="tips">*</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label" style="font-weight: 500">授权模式：</label>

                <div class="col-sm-9">
                    <div class="checkbox" style="float: left;margin-right: 10px;">
                        <label>
                            <input name="form-field-checkbox" type="checkbox" class="ace" value="read write" />
                            <span class="lbl">授权码模式</span>
                        </label>
                    </div>
                    <div class="checkbox" style="float: left;margin-right: 10px;">
                        <label>
                            <input name="grantTypes" type="checkbox" class="ace" value="read" />
                            <span class="lbl">密码模式</span>
                        </label>
                    </div>
                    <div class="checkbox" style="float: left;margin-right: 10px;">
                        <label>
                            <input name="grantTypes" type="checkbox" class="ace" value="read" />
                            <span class="lbl">客户端模式</span>
                        </label>
                    </div>
                    <div class="checkbox" style="float: left;margin-right: 10px;">
                        <label>
                            <input name="grantTypes" type="checkbox" class="ace" value="read" />
                            <span class="lbl">简化模式</span>
                        </label>
                    </div>
                    <span class="tips">*</span>
                </div>
            </div>
            <div class="form-group">
                <label for="description" class="col-sm-3 control-label" style="font-weight: 500">描述：</label>

                <div class="col-sm-9">
                    <input type="text" class="form-control" id="description" name="description"
                           required="true" style="width: 70%;float: left;" />
                    <span class="tips">*</span>
                </div>
            </div>
           <div class="form-group">
                <label class="col-sm-5 control-label">&nbsp;</label>

                <div class="col-sm-7">
                    <button type="submit" class="btn btn-primary" id="J_submit">保存</button>
                </div>
            </div>
        </form>
    </div>
</div>

<script type="text/javascript">
    /**
     * 提交数据
     */
    $('#J_submit').on('click',function(){
        submitData();
    });

    function submitData() {
        if (true) {
            $.ajax({
                type:'POST',
                url:'${ctx}/${frameworkPath}/client/api/create',
                async:false,
                dataType:'json',
                traditional:true,
                data:data1,
                beforeSend: function (XMLHttpRequest) {
                    //发送前显示遮罩层，无法再次点击，只能等请求结束后才能进行页面操作
                    $('#J_submit').hide();
                },
                success:function(data){
                    if (data.success) {
                        parent.lui.success('保存成功');

                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    } else {
                        parent.lui.fail("保存失败:" + data.message);
                    }
                },
                error: function(XmlHttpRequest, textStatus, errorThrown){
                    $('#J_submit').show();
                    parent.lui.fail('添加数据失败！');
                },
                complete: function (jsondata, stat) {
                    $('#J_submit').show();
                }
            });
        } else {
            return;
        }
    };
</script>
</body>
</html>
